//
//  SLWBVisitorLoginView.swift
//  SinaWeiBo
//
//  Created by 孙磊 on 15/10/6.
//  Copyright © 2015年 Sun. All rights reserved.
//

import UIKit

class SLWBVisitorLoginView: UIView {
    //环绕图
    @IBOutlet weak var smallIcon: UIImageView!
    //中间的小房子
    @IBOutlet weak var iconView: UIImageView!
    //详细信息
    @IBOutlet weak var tipLabel: UILabel!
    
    func setUserInfo(imageName name:String,title:String,isHome:Bool = false){
        iconView.image = UIImage(named: name)
        tipLabel.text = title
        smallIcon.hidden = !isHome
        if isHome{
            startAnimation()
        }
    }
    
    //MARK: 旋转动画
    private func startAnimation(){
        //创建一个核心动画对象
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        //设置核心动画的重复次数 --- 为无数次
        anim.repeatCount = MAXFLOAT
        //设置核心动画的持续时间
        anim.duration = 15
        //设置核心动画的运动轨迹
        anim.toValue = 2 * M_PI
        
        //设置当动画页面处于非活跃状态下不会移除图层（默认为会）
        anim.removedOnCompletion = false
        
        //将动画设置给对象
        smallIcon.layer.addAnimation(anim, forKey: nil)
        
    }
    
    //点击注册按钮
    @IBAction func registerAction(sender: AnyObject) {
    }
    //点击登录按钮
    @IBAction func loginAction(sender: AnyObject) {
    }
    
}
